<template>
  <div class="app-container">
       <div class="custom_card_0">
          <el-form
            inline
            :model="form"
            size="mini"
            ref="queryForm"
            label-width="70px"
            label-position="right"
            v-show="showSearch"
          >
            <el-form-item label="订单编号" prop="orderNo">
              <el-input
                v-model="form.orderNo"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
                placeholder="请输入订单编号"
              ></el-input>
            </el-form-item>
            <el-form-item label="预定车型" v-if="false" prop="modelId">
              <el-select
                v-model="form.modelId"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
              >
                <el-option label="全部" :value="0"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户名称" prop="memberName">
              <el-input
                v-model="form.memberName"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
                placeholder="请输入客户名称"
              ></el-input>
            </el-form-item>
            <el-form-item label="客户类型" prop="memberType">
              <el-select
                v-model="form.memberType"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
              >
                <template v-for="dict in dict.type.memberType">
                  <el-option
                    :label="dict.label"
                    :value="dict.value"
                    :key="dict.value"
                  ></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="预约门店" prop="reserveTakeStoreId">
              <el-select
                v-model="form.reserveTakeStoreId"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
              >
                <el-option
                  v-for="item in storeOptions"
                  :key="item.storeId"
                  :label="item.storeName"
                  :value="item.storeId"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="订单来源" prop="orderSource">
              <el-select
                v-model="form.orderSource"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
              >
                <template v-for="dict in dict.type.sys_order_source">
                  <el-option
                    :label="dict.label"
                    :value="dict.value"
                    :key="dict.value"
                  ></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="订单状态" prop="orderStatus">
              <el-select
                v-model="form.orderStatus"
                clearable
                @1clear="handleQuery"
                style="width: 220px"
              >
                <template v-for="dict in dict.type.long_order_status">
                  <el-option
                    :label="dict.label"
                    :value="dict.value"
                    :key="dict.value"
                  ></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="车牌号" prop="carNo">
              <el-input
                v-model="form.carNo"
                clearable
                style="width: 220px"
                placeholder="请输入车牌号"
              ></el-input>
            </el-form-item>

            <el-form-item label="下单时间" prop="startTime">
              <el-date-picker
                clearable
                style="width: 220px"
                size="small"
                v-model="time"
                type="datetimerange"
                range-separator="至"
                value-format="yyyy-MM-dd HH:mm:ss"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="handleQuery"
                >搜索</el-button
              >
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
                >重置</el-button
              >
            </el-form-item>
          </el-form>
       </div>
          <div class="custom_card">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          class="first-plain-btn" size="medium"
          icon="el-icon-plus"
          @click="handleAdd"
          v-hasPermi="['order:longOrder:add']"
          >新&nbsp;&nbsp;增</el-button
        >
      </el-col>
      <right-toolbar
        :showFolding="true"
        :showSearch.sync="showSearch"
        :lineFolding.sync="lineFolding"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="list"
      @selection-change="handleSelectionChange"
      border
    >
      <el-table-column label="订单编号" align="center" min-width="200" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span style="font-size: 14px; color: #1890ff;cursor:pointer;" @click="handleDetail(row)">{{ row.orderNo }}</span>
        </template>
      </el-table-column>
      <el-table-column label="承租人"  align="center"  min-width="200" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.memberName }}&nbsp;&nbsp;</span>
          <span :style="{display:lineFolding?'block':'inline-block'}">
             {{ row.memberPhone }}&nbsp;&nbsp;
            </span>
          <span v-if="row.memberType">
            <dict-tag
                style="display: inline-block"
                :options="dict.type.memberType"
                :value="row.memberType"
              />客户&nbsp;&nbsp;
            </span>
        </template>
      </el-table-column>
      <el-table-column label="预计取还时间" align="center"  min-width="180"  show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span style="color: #d9001b" :style="{display:lineFolding?'block':'inline-block'}">取：{{ row.rentalStartTime }}&nbsp;&nbsp;&nbsp;</span>
          <span style="color: #dd5d1b">还：{{ row.rentalEndTime }}&nbsp;&nbsp;&nbsp;</span>
        </template>
      </el-table-column>
      <el-table-column label="租期" align="center"  show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.tenancyTerm }}个月</span>
        </template>
      </el-table-column>
      <el-table-column label="预定车型" align="center"  min-width="150" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.modelName }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="车牌号"
        align="center"
        prop="carNo"
        min-width="130"
        show-overflow-tooltip
      />
      <el-table-column label="取还车门店" align="center"  min-width="150" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span style="color: #d9001b" :style="{display:lineFolding?'block':'inline-block'}">取：{{ row.reserveTakeStoreName }}&nbsp;&nbsp;&nbsp;</span>
          <span style="color: #dd5d1b">还：{{ row.reserveAlsoStoreName }}&nbsp;&nbsp;&nbsp;</span>
        </template>
      </el-table-column>
      <el-table-column label="订单来源" align="center" min-width="150" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <dict-tag
            :options="dict.type.sys_order_source"
            :value="row.orderSource"
          />
        </template>
      </el-table-column>
      <el-table-column label="订单状态" min-width="200" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>
            <dict-tag
              style="display: inline-block"
              :options="dict.type.long_order_status"
              :value="row.orderStatus"
            />
          </span>
          <span v-if="row.orderStatus ==3"  :style="{display:lineFolding?'block':'inline-block'}">
            <count-down
              :endTime="row.rentalStartTime"
              endText="已超时"
              startText="距离取车时间"
            />
          </span>
          <span v-if="row.orderStatus == 4"  :style="{display:lineFolding?'block':'inline-block'}">
            <count-down
              :endTime="row.rentalEndTime"
              endText="已超时"
              startText="距离还车时间"
            />
          </span>
        </template>
      </el-table-column>
      <el-table-column label="分配业务员" align="center"  min-width="100" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.salesman }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="下单时间"
        align="center"
        min-width="130"
        show-overflow-tooltip
        prop="createTime"
      />
      <el-table-column label="操作" width="150"  fixed="left" align="center">
        <!-- 订单状态（0=待支付,1=待分配,2=待排车,3=待取车,4=用车中,5=车损结算,6=押金结算,7=违章处理,8=违章结算,9=已完成,10=已取消,11=结算退款中） -->
        <template slot-scope="{ row }">
          <el-button
            type="text"
            size="mini"
            @click="handleEdit(row)"
            v-if="row.orderStatus == 0"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:edit']"
            >编辑订单</el-button
          >
<!--          <el-button-->
<!--            type="text"-->
<!--            size="mini"-->
<!--            @click="orderRefund(row)"-->
<!--            v-if="-->
<!--              row.orderStatus == 1 ||-->
<!--              (row.orderStatus == 0 && row.depositIspay == 2)-->
<!--            "-->
<!--            icon="el-icon-delete"-->
<!--            v-hasPermi="['order:longOrder:cancel']"-->
<!--            >订单退款</el-button-->
<!--          >-->
          <el-button
            type="text"
            size="mini"
            @click="handleDingdan(row)"
            v-if="row.orderStatus == 1"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:distribution']"
            >订单分配</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="handlePeiche(row)"
            v-if="row.orderStatus == 2"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:supplyCar']"
            >订单配车</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="handleJiaocheyanche(row)"
            v-if="row.orderStatus == 3"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:delivery']"
            >交车验车</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="handleHuancheyanche(row)"
            v-if="row.orderStatus == 4"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:alsoCarTest']"
            >还车验车</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="handleDepositRefund(row)"
            v-if="row.orderStatus == 5"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:depositRefund']"
            >押金结算</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="handleFeiyongmingxi(row)"
            v-if="row.orderStatus > 6"
            icon="el-icon-edit"
            v-hasPermi="['order:longOrder:costDetail']"
            >费用明细</el-button
          >
          <el-dropdown
            size="mini"
            @command="(command) => handleCommand(command, row)"
            icon="el-icon-edit"
            v-hasPermi="[
              'order:longOrder:costDetail',
              'order:longOrder:log',
              'order:longOrder:query',
            ]"
          >
            <span class="el-dropdown-link">
              <i class="el-icon-d-arrow-right el-icon--right"></i>更多
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                command="handleCancel"
                v-if="row.orderStatus == 0 && row.depositIspay == 1"
                icon="el-icon-delete"
                v-hasPermi="['order:longOrder:cancel']"
              >取消订单</el-dropdown-item
              >
              <el-dropdown-item
                command="handleFeiyongmingxi"
                icon="el-icon-search"
                v-hasPermi="['order:longOrder:costDetail']"
                v-if="row.orderStatus < 7"
                >费用明细</el-dropdown-item
              >
              <el-dropdown-item
                command="handleDetail"
                icon="el-icon-search"
                v-hasPermi="['order:longOrder:query']"
                >订单详情</el-dropdown-item
              >
              <el-dropdown-item
                command="handleLog"
                icon="el-icon-search"
                v-hasPermi="['order:longOrder:log']"
                >订单日志</el-dropdown-item
              >
              <template v-if="row.orderStatus != 8">
                <el-dropdown-item
                  command="handleJiaocheyanchelist"
                  icon="el-icon-search"
                  v-hasPermi="['order:longOrder:deliveryInfo']"
                  v-if="row.orderStatus > 3"
                  >交车验车单</el-dropdown-item
                >
                <el-dropdown-item
                  command="handleHuancheyanchelist"
                  icon="el-icon-search"
                  v-hasPermi="['order:longOrder:alsoCarTest']"
                  v-if="row.orderStatus > 4"
                  >还车验车单</el-dropdown-item
                >
              </template>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="pageNum"
      :limit.sync="pageSize"
      @pagination="getList"
    />
          </div>
    <!-- 订单新增/编辑 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvAdd ref="MmvAdd" v-if="open" :id="nowOrderNo"></MmvAdd>
      <div slot="footer">
        <el-button @click="open = false">取消</el-button>
        <el-button
          type="primary"
          @click="submitForm"
          :loading="addSubmitLoading"
          >确定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      title="订单详情"
      :visible.sync="showdetail"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDetail
        ref="MmvDetail"
        v-if="showdetail"
        :orderNo="nowOrderNo"
      ></MmvDetail>
      <div slot="footer">
        <el-button @click="showdetail = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="订单退款"
      :visible.sync="showorderRefund"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvOrderRefund
        ref="MmvOrderRefund"
        v-if="showorderRefund"
        :orderNo="nowOrderNo"
        @close="showorderRefund = false"
      ></MmvOrderRefund>
    </el-dialog>

    <el-dialog
      title="订单分配"
      :visible.sync="showdingdanfenpei"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDingdanfenpei
        ref="MmvDingdanfenpei"
        v-if="showdingdanfenpei"
        :orderNo="nowOrderNo"
        @close="showdingdanfenpei = false"
      ></MmvDingdanfenpei>
      <div slot="footer">
        <el-button @click="showdingdanfenpei = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="费用明细"
      :visible.sync="showfeiyongmingxi"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvCostDetail
        ref="MmvCostDetail"
        v-if="showfeiyongmingxi"
        :orderNo="nowOrderNo"
        @close="showfeiyongmingxi = false"
      ></MmvCostDetail>
    </el-dialog>

    <el-dialog
      title="去配车"
      :visible.sync="showpeiche"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvPeiche
        ref="MmvPeiche"
        v-if="showpeiche"
        :orderNo="nowOrderNo"
        @close="showpeiche = false"
      ></MmvPeiche>
      <div slot="footer">
        <el-button @click="showpeiche = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="交车验车"
      :visible.sync="showjiaocheyanche"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDelivery
        ref="MmvDelivery"
        v-if="showjiaocheyanche"
        :orderNo="nowOrderNo"
        :type="1"
        @close="showjiaocheyanche = false"
      ></MmvDelivery>
    </el-dialog>

    <el-dialog
      title="还车验车"
      :visible.sync="huancheyanche"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDelivery
        ref="MmvDelivery"
        v-if="huancheyanche"
        :orderNo="nowOrderNo"
        :type="2"
        @close="huancheyanche = false"
      ></MmvDelivery>
    </el-dialog>

    <el-dialog
      title="交车验车单"
      :visible.sync="showjiaocheyanchelist"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDeliveryList
        ref="MmvDeliveryList"
        v-if="showjiaocheyanchelist"
        :orderNo="nowOrderNo"
        :type="1"
        @close="showjiaocheyanchelist = false"
      ></MmvDeliveryList>
      <div slot="footer">
        <el-button @click="showjiaocheyanchelist = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="还车验车单"
      :visible.sync="huancheyanchelist"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvDeliveryList
        ref="MmvDeliveryList"
        v-if="huancheyanchelist"
        :orderNo="nowOrderNo"
        :type="2"
        @close="huancheyanchelist = false"
      ></MmvDeliveryList>
    </el-dialog>

    <el-dialog
      title="订单日志"
      :visible.sync="showdingdanlog"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvLog ref="MmvLog" v-if="showdingdanlog" :orderNo="nowOrderNo"></MmvLog>
      <div slot="footer">
        <el-button @click="showdingdanlog = false">关闭</el-button>
      </div>
    </el-dialog>

    <!--  <el-dialog title="押金扣款明细" :visible.sync="showsettlement" width="1000px" destroy-on-close append-to-body @close="closeDiolog">
            <MmvSettlement ref="MmvSettlement" v-if="showsettlement" :orderNo="nowOrderNo" :type="1"></MmvSettlement>
            <div slot="footer">
                <el-button @click="OverDepositSettlement" type="primary">完成结算</el-button>
                <el-button @click="showsettlement=false">关闭</el-button>
            </div>
        </el-dialog> -->

    <el-dialog
      title="押金结算"
      :visible.sync="showDepositRefund"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <DepositRefund
        ref="DepositRefund"
        v-if="showDepositRefund"
        :orderNo="nowOrderNo"
      ></DepositRefund>
      <div slot="footer">
        <el-button @click="OverDepositSettlement" type="primary"
          >完成结算</el-button
        >
        <el-button @click="showDepositRefund = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="违章结算"
      :visible.sync="showIllegalProcessing"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <IllegalProcessing
        ref="IllegalProcessing"
        v-if="showIllegalProcessing"
        :orderNo="nowOrderNo"
        @close="showIllegalProcessing = false"
      ></IllegalProcessing>
    </el-dialog>

    <el-dialog
      :title="refundConfirmTitle"
      :visible.sync="showDepositRefundConfirm"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvRefundConfirm
        ref="MmvRefundConfirm"
        v-if="showDepositRefundConfirm"
        :orderNo="nowOrderNo"
        :type="refundConfirmType"
        @close="showDepositRefundConfirm = false"
      ></MmvRefundConfirm>
    </el-dialog>

    <el-dialog
      title="申请换车"
      :visible.sync="showChangeCar"
      width="1000px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <MmvChageCar
        ref="MmvChageCar"
        :orderNo="nowOrderNo"
        @close="showChangeCar = false"
      ></MmvChageCar>
    </el-dialog>
    <el-dialog
      :title="pingzheng.title"
      :visible.sync="pingzheng.show"
      width="800px"
      destroy-on-close
      append-to-body
      @close="closeDiolog"
    >
      <PingZheng
        ref="PingZheng"
        v-if="pingzheng.show"
        :bizId="nowOrderNo"
        :bizType="pingzheng.bizType"
        @submit="pingCallBack"
      ></PingZheng>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '@/api/longOrder/index'
import { getAllStore } from '@/api/store/store'
import MmvAdd from './add.vue'
import MmvDetail from './detail.vue'
import MmvPeiche from './pageche.vue'
import MmvDingdanfenpei from './dingdanfenpei.vue'
import MmvDelivery from './delivery.vue'
import MmvDeliveryList from './delivery-detail.vue'
import MmvCostDetail from './costDetail.vue'
import MmvLog from './log.vue'
import IllegalProcessing from './IllegalProcessing.vue'
import DepositRefund from './depositRefund.vue'
import MmvRefundConfirm from './depositRefundConfirm.vue'
import PingZheng from '../../components/zhifupingzheng.vue'
import countDown from './components/countDown.vue'
import MmvOrderRefund from './orderRefund.vue'

export default {
  name:'Basic',
  components: {
    MmvAdd,
    MmvDetail,
    MmvPeiche,
    MmvDingdanfenpei,
    MmvDelivery,
    MmvDeliveryList,
    MmvCostDetail,
    MmvLog,
    IllegalProcessing,
    DepositRefund,
    PingZheng,
    countDown,
    MmvOrderRefund,
    MmvRefundConfirm,
  },
  dicts: ['memberType', 'sys_order_source', 'long_order_status'],
  data() {
    return {
      refundConfirmTitle: '',
      refundConfirmType: 3,
      showDepositRefundConfirm: false,
      showorderRefund: false,
      pingzheng: {
        title: '',
        show: false,
        bizType: 0,
      },
      form: {
        orderNo: '', //订单编号
        modelId: '', //预定车型id
        memberName: '', //客户名称
        memberType: '', //客户类型(字典:memberType)
        rentalTime: [], // 预定租赁时间
        reserveTakeStoreId: '', //预约门店
        orderSource: '', //订单来源(字典:sys_order_source)
        orderStatus: '', //订单状态(字典:long_order_status)
      },
      // orderNo: '', //订单编号
      // modelId: '', //预定车型id
      // memberName: '', //客户名称
      // memberType: '', //客户类型(字典:memberType)
      // rentalTime: [], // 预定租赁时间
      // reserveTakeStoreId: '', //预约取车门店
      // reserveAlsoStoreId: '', //预约还车门店
      // orderSource: '', //订单来源(字典:sys_order_source)
      // orderStatus: '', //订单状态(字典:long_order_status)
      pageNum: 0, //页码   必选
      pageSize: 10, //每页显示数据 必选
      // 门店数据
      storeOptions: [],
      addSubmitLoading: false,
      loading: true,
      list: [],
      total: 0,
      // 非多个禁用
      multiple: true,
      // 弹出层标题
      title: '',
      // 显示搜索条件
      showSearch: true,
      lineFolding: false,
      // 是否显示弹出层
      nowOrderNo: null, // 当前选择订单id
      open: false, // 显示新增/编辑
      showdetail: false, // 显示订单详情
      showpeiche: false, // 显示配车
      showdingdanfenpei: false, // 显示订单分配
      showjiaocheyanche: false, // 显示交车验车
      showjiaocheyanchelist: false, // 显示交车验车单
      huancheyanche: false, // 显示还车验车
      huancheyanchelist: false, // 显示还车验车单
      showfeiyongmingxi: false, // 显示费用明细
      showdingdanlog: false, // 显示订单日志
      showsettlement: false, // 显示押金结算明细
      showDepositRefund: false, // 显示押金结算退款
      showIllegalProcessing: false, // 显示违章结算明细
      finalStatement: false, // 显示结算单
      showChangeCar: false, // 显示申请换车
    }
  },
  mounted() {
    this.getList()
    this.getAllStore()
  },
  activated() {
    this.getList()
  },
  methods: {
    params() {
      const params = {
        orderNo: this.form.orderNo, //订单编号
        modelId: this.form.modelId, //预定车型id
        memberName: this.form.memberName, //客户名称
        memberType: this.form.memberType, //客户类型(字典:memberType)
        rentalStartTime: this.form.rentalTime[0], //预定租赁开始时间
        rentalEndTime: this.form.rentalTime[1], //预定租赁结束时间
        reserveTakeStoreId: this.form.reserveTakeStoreId, //预约取车门店
        orderSource: this.form.orderSource, //订单来源(字典:sys_order_source)
        orderStatus: this.form.orderStatus, //订单状态(字典:long_order_status)
        pageNum: this.pageNum, //页码   必选
        pageSize: this.pageSize, //每页显示数据 必选
      }
      return params
    },
    /** 查询部门下拉树结构 */
    getAllStore() {
      getAllStore().then((response) => {
        this.storeOptions = response.data
      })
    },
    /** 查询列表 */
    getList() {
      this.loading = true
      let params = this.params()
      api.index(params).then((response) => {
        this.list = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case 'handleFeiyongmingxi':
          this.handleFeiyongmingxi(row)
          break
        case 'handleLog':
          this.handleLog(row)
          break
        case 'handleDetail':
          this.handleDetail(row)
          break
        case 'handleJiaocheyanchelist':
          this.handleJiaocheyanchelist(row)
          break
        case 'handleHuancheyanchelist':
          this.handleHuancheyanchelist(row)
          break
        case 'handleCancel':
          this.handleCancel(row)
          break
        default:
          break
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.nowOrderNo = null
      // this.reset();
      this.open = true
      this.title = '新增订单'
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const memberNos = row.memberNo || this.ids
      this.$modal
        .confirm('是否确认删除数据项？')
        .then(function () {
          return delBasic(memberNos)
        })
        .then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal
        .confirm('是否确认导出所有数据项？')
        .then(() => {
          this.exportLoading = true
          return exportBasic(queryParams)
        })
        .then((response) => {
          this.$download.name(response.msg)
          this.exportLoading = false
        })
        .catch(() => {})
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.orderNo)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 订单详情按钮 */
    handleDetail(row) {
      this.nowOrderNo = row.orderNo
      this.$router.push({
        path: '/longBasic/detail',
        query: { orderNo: row.orderNo }
      })
    },
    /** 删除按钮操作 */
    handleCancel(row) {
      const ids = row.orderNo || this.ids
      this.$modal
        .confirm('是否确认取消吗？')
        .then(function () {
          return api.cancel(ids, 0)
        })
        .then(() => {
          this.getList()
          this.$modal.msgSuccess('取消成功')
        })
        .catch(() => {})
    },
    orderRefund(row) {
      this.nowOrderNo = row.orderNo
      this.showorderRefund = true
    },
    /** 编辑按钮操作 */
    handleEdit(row) {
      this.nowOrderNo = row.orderNo
      this.open = true
      this.title = '编辑订单'
    },
    /** 配车 */
    handlePeiche(row) {
      this.nowOrderNo = row.orderNo
      this.showpeiche = true
    },
    /** 订单日志 */
    handleLog(row) {
      this.nowOrderNo = row.orderNo
      this.showdingdanlog = true
    },
    /** 订单分配 */
    handleDingdan(row) {
      this.nowOrderNo = row.orderNo
      this.showdingdanfenpei = true
    },
    /** 费用明细 */
    handleFeiyongmingxi(row) {
      this.nowOrderNo = row.orderNo
      this.showfeiyongmingxi = true
    },
    /** 交车验车 */
    handleJiaocheyanche(row) {
      this.nowOrderNo = row.orderNo
      this.showjiaocheyanche = true
    },
    /** 交车验车单 */
    handleJiaocheyanchelist(row) {
      this.nowOrderNo = row.orderNo
      this.showjiaocheyanchelist = true
    },
    /** 还车验车 */
    handleHuancheyanche(row) {
      this.nowOrderNo = row.orderNo
      this.huancheyanche = true
    },
    /** 还车验车单 */
    handleHuancheyanchelist(row) {
      this.nowOrderNo = row.orderNo
      this.huancheyanchelist = true
    },
    /** 押金结算 */
    handleSettlement(row) {
      this.nowOrderNo = row.orderNo
      this.showsettlement = true
    },
    /** 押金结算退款 */
    handleDepositRefund(row) {
      this.nowOrderNo = row.orderNo
      this.showDepositRefund = true
    },
    /** 违章押金结算退款 */
    handleIllegalProcessing(row) {
      this.nowOrderNo = row.orderNo
      this.showIllegalProcessing = true
    },
    OverDepositSettlement() {
      this.$modal.confirm('提交后将不可编辑,是否确认结算？').then(() => {
        api.overDepositSettlement(this.nowOrderNo).then((response) => {
          this.$message.success(response.msg)
          this.showDepositRefund = false
        })
      })
    },
    doDepositRefund(type, orderNo) {
      this.nowOrderNo = orderNo
      this.refundConfirmType = type
      switch (type) {
        case 3:
          this.refundConfirmTitle = '租车押金结算补缴'
          this.showDepositRefundConfirm = true
          break
        case 4:
          this.refundConfirmTitle = '租车押金结算退款'
          this.showDepositRefundConfirm = true
          break
      }
    },
    pingCallBack(type) {
      this.pingzheng.show = false
      if (type == 8) {
        api.cancel(this.nowOrderNo).then((response) => {
          this.$message.success(response.msg)
          this.closeDiolog()
        })
      } else {
        api.depositRefund(this.nowOrderNo).then((response) => {
          this.$message.success(response.msg)
          this.closeDiolog()
        })
      }
    },
    /** 违章结算 */
    handleSettlement2(row) {
      this.nowOrderNo = row.orderNo
      this.showsettlement2 = true
    },
    /** 违章结算单 */
    showFinalStatement(row) {
      this.nowOrderNo = row.orderNo
      this.finalStatement = true
    },
    /** 通用关闭弹窗处理方法 */
    closeDiolog() {
      this.nowOrderNo = null
      // this.handleQuery();
      this.getList()
    },
    /** 提交订单 */
    submitForm() {
      this.addSubmitLoading = true
      setTimeout(() => {
        this.addSubmitLoading = false
      }, 2e3)
      this.$refs['MmvAdd']?.emitData().then((form) => {
        if (this.nowOrderNo != null) {
          api.put(form).then((response) => {
            this.$modal.msgSuccess('修改成功')
            this.open = false
            this.getList()
          })
        } else {
          api.add(form).then((response) => {
            this.$modal.msgSuccess('新增成功')
            this.open = false
            this.getList()
          })
        }
      })
    },
    xxxxxx() {},
  },
}
</script>
